package com.example.a79273.shandianban.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * 有人页面中的viewpager的适配器
 */
public class YouRenPagerAdapter extends PagerAdapter {
    private List<ImageView> mData;

    public YouRenPagerAdapter(List<ImageView> data) {
        mData = data;
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {

        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView view = mData.get(position);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(mData.get(position));

    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}
